package pyf.gaoji;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @author pengyifeng
 * @version 5.1
 * @ClassName ThreadPoolDemo.java
 * @Description 线程池
 * @createTime 2021年07月27日 17:48:00
 */
public class ThreadPoolDemo {

    public static void main(String[] args) {
        //阿里建议手动创建线程池
        //创建线程池
        ExecutorService service= Executors.newFixedThreadPool(10);

        //执行线程
        service.execute(new MyThread());
        service.execute(new MyThread());
        service.execute(new MyThread());
        service.execute(new MyThread());
        //关闭连接
        service.shutdown();
    }
static class MyThread implements  Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());
    }
}
}
